package com.zds.dao.impl;

import com.zds.dao.UserDao;
import com.zds.entity.User;
import com.zds.mapper.UserMapper;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;

/**
 * @className:UserDaoImpl
 * @date: 2024/12/14 下午4:42
 * @description:
 */
@Repository("userDao")
public class UserDaoImpl implements UserDao, InitializingBean {
    @Autowired
    private UserMapper userMapper;
    /**
     * 无参构造方法实例化
     */
    public UserDaoImpl() {
//        System.out.println("UserDaoImpl无参构造方法实例化");
    }

    /**
     * 有参构造函数实例化
     * @param name
     */
    public UserDaoImpl(String name) {
//        System.out.println("UserDaoImpl有参构造函数实例化，参数Name:"+name);
    }
    @PostConstruct
    public void init(){
        System.out.println("初始化方法");
    }
    @PreDestroy
    public void destory(){
        System.out.println("销毁方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("aterPropertiesSet方法执行");
    }

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }
}
